<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<title>所有日志</title>
<link href="${pageContext.request.contextPath}/css/base.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/share.js"></script>
<style type="text/css">

a.articleCategoryA:link,a.articleCategoryA:visited {
	color: #3355ff;
	text-decoration: none;
	font-size:14px;
}

a.articleCategoryA:hover,a.articleCategoryA:active {
	color: #ffffff;
	background: #3355ff;
	font-size:14px;
}
a.articleTitleA:link,a.articleTitleA:visited {
	color: #3355ff;
	text-decoration: none;
	font-size:16px;
	font-weight:bold;
}

a.articleTitleA:hover,a.articleTitleA:active {
	color: #ffffff;
	background: #3355ff;
	font-size:16px;
	font-weight:bold;
}

a.articleContentA:link,a.articleContentA:visited {
	color: #000000;
	text-decoration: none;
	font-size:14px;
}

a.articleContentA:hover,a.articleContentA:active {
	color: #3355ff;
	font-size:14px;
}
.articleInfoFont{
	color: #777777;
	font-size:14px;
}
.articleTable {
	width:640px;
	border-top:1px dashed #cccccc;
	overflow:hidden;
}
</style>
<script type="text/javascript">
//var listArticleByCategoryIdUrl="<%=request.getContextPath()%>/article/list/category/";
/*function chooseCategory(categoryid){
	if(categoryid!=0){
	 window.location.href=listArticleByCategoryIdUrl+categoryid+".html";
	}
}*/
function Article(webSite,userId){
	
	this.listArticleByCategoryIdUrl=webSite+"/article/list/category/"+userId+"/";
	this.listArticleByUserIdUrl=webSite+"/article/list/user/"+userId+".html";
		
	this.chooseCategory=function(categoryid){
		if(categoryid!=0){
			window.location.href=this.listArticleByCategoryIdUrl+categoryid+".html";
		}
		else{
			window.location.href=this.listArticleByUserIdUrl;
		}
	}
}
var article=new Article('/skyline',${requestScope.OWNER_ID});
</script>
</head>
<body>
<skyline:setSessionAttrToVar var="user" key="SESSION_USER"/>
<c:set var="ownerId" scope="page" value="${requestScope.OWNER_ID}" />
<c:set var="categories" scope="page" value="${requestScope.CATEGORIES}" />
<c:set var="curCategory" scope="page" value="${requestScope.CURRENT_CATEGORY}" />
选择分类：<select id="categories" onchange="article.chooseCategory(this.options[this.options.selectedIndex].value)">

<c:forEach var="category" items="${categories }">
<option value="${category.id }" <c:choose><c:when test="${curCategory==category.id }"> selected="selected"</c:when> </c:choose> >${category.categoryName }  (${category.articleNum })</option>
</c:forEach>
</select>
<c:choose>
	<c:when test="${user.id==ownerId}">
	<a href="<%=request.getContextPath()%>/article/category/manage.html">管理分类</a>
	</c:when>
</c:choose><br>
<skyline:page page="${requestScope.page }" url="" maxSize="6" curClass="curclass curclass2" curStyle="curstyle" normalClass="norClass norclass2" normalStyle="norstyle" decStr="%s"/>
<c:set var="articles" value="${requestScope.ARTICLES}"></c:set>
<c:forEach var="article" items="${articles}">
	<table class="articleTable">
		<tr>
			<td colspan='2'>
			<a class="articleTitleA" href="<%=request.getContextPath()%>/article/view/${article.id}.html">${article.title}</a>
			</td>
		</tr>
		<tr>
			<td colspan='2'>
			<font class="articleInfoFont">
			发表于:<fmt:formatDate value="${article.createTime}" type="both"/>
			</font>
			&nbsp;
			<font class="articleInfoFont">(分类:</font>
			<a class="articleCategoryA" href="<%=request.getContextPath()%>/article/list/category/${article.categoryId}.html">${article.categoryName}</a>
			<font class="articleInfoFont">)</font>
			</td>
		</tr>
		<tr>
			<td colspan='2'>
			<p><a class="articleContentA" href="<%=request.getContextPath()%>/article/view/${article.id}.html">${article.digest}......</a></p>
			</td>
		</tr>
		<tr>
			<td width='50%' align='left'>
		<font class="articleInfoFont">阅读(${article.visitNum})&nbsp;&nbsp;分享(${article.shareNum})&nbsp;&nbsp;评论(${article.commentNum})</font>
			</td>
			<td width='50%' align='right'>
			<c:choose>
				<c:when test="${user!=null&&ownerId!=null&&user.id==ownerId}">
					<a href="<%=request.getContextPath() %>/article/modify/${article.id}.html" class="modifyA">编辑</a>&nbsp;
					<a href="<%=request.getContextPath() %>/article/delete/${article.id}.html" onclick="return confirm('你确定删除此日志么?\n\n提示:删除日志后将不可恢复.');" class="deleteA">删除</a>&nbsp;
				</c:when>
			</c:choose>
			<skyline:share type="ARTICLE" value="分享" curClass="shareA" resourceId="${article.id }"/>
			&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
		</tr>
	</table>
</c:forEach>
<br>
<skyline:page page="${requestScope.page }" url="" maxSize="6" curClass="curclass curclass2" curStyle="curstyle" normalClass="norClass norclass2" normalStyle="norstyle" decStr="%s"/>
</body>
</html>